package app.beit.fintrack.service.convert;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import app.beit.fintrack.bean.summary.SummaryZoneBean;
import app.beit.fintrack.entity.summary.SummaryZone;

public class SummaryZoneConvert {

	/**
	 * Convert Entity To Bean
	 * 
	 * @param entity
	 * @return SummaryZoneBean
	 */
	public static SummaryZoneBean entityToBean(final SummaryZone entity) {
		final SummaryZoneBean bean = new SummaryZoneBean();

		bean.setAmount(entity.getAmount() == null ? new BigDecimal("0") : entity.getAmount());
		bean.setZoneId(entity.getZoneId());
		bean.setZoneName(entity.getZoneName());

		return bean;
	}

	/**
	 * Convert Bean to Entity
	 * 
	 * @param bean
	 * @return SummaryZone
	 */
	public static SummaryZone beanToEntity(final SummaryZoneBean bean){
		final SummaryZone entity = new SummaryZone();

		entity.setAmount(bean.getAmount() == null ? new BigDecimal("0") : bean.getAmount());
		entity.setZoneId(bean.getZoneId());
		entity.setZoneName(bean.getZoneName());

		return entity;
	}

	/**
	 * Convert List Entity to List Bean
	 * 
	 * @param entities
	 * @return List SummaryZoneBean
	 */
	public static List<SummaryZoneBean> entityToBean(final List<SummaryZone> entities){
		final List<SummaryZoneBean> beans = new ArrayList<SummaryZoneBean>();

		for (final SummaryZone entity : entities) {
			beans.add(SummaryZoneConvert.entityToBean(entity));
		}

		return beans;
	}

	/**
	 * Convert List Bean to List Entity
	 * 
	 * @param beans
	 * @return List SummaryZone
	 */
	public static List<SummaryZone> beanToEntity(final List<SummaryZoneBean> beans){
		final List<SummaryZone> entities = new ArrayList<SummaryZone>();

		for (final SummaryZoneBean bean : beans) {
			entities.add(SummaryZoneConvert.beanToEntity(bean));
		}

		return entities;
	}

}
